#include "Keys.h"

Keys::Keys()
{
}

Keys::~Keys()
{
}

void Keys::key_console( int key )
{
	switch( key )
	{
	case K_KP_SLASH:
		key = '/';
		break;
	case K_KP_MINUS:
		key = '-';
		break;
	case K_KP_PLUS:
		key = '+';
		break;
	case K_KP_HOME:
		key = '7';
		break;
	case K_KP_UPARROW:
		key = '8';
		break;
	case K_KP_PGUP:
		key = '9';
		break;
	case K_KP_LEFTARROW:
		key = '5';
		break;
	case K_KP_RIGHTARROW:
		key = '6';
		break;
	case K_KP_END:
		key = '1';
		break;
	case K_KP_DOWNARROW:
		key = '2';
		break;
	case K_KP_PGDN:
		key = '3';
		break;
	case K_KP_INS:
		key = '0';
		break;
	case K_KP_DEL:
		key = '.';
		break;
	}

	if ( ( toupper( key ) == 'V' && keydown[K_CTRL] ) ||
		( ( ( key == K_INS ) || ( key == K_KP_INS ) ) && keydown[K_SHIFT] ) )
	{
	}
}

void Keys::key_event( int key, bool down, unsigned int time )
{
	char *kb;
	char command[1024];

	if ( key_waiting == -1 )
	{
		if ( down )
			key_waiting = key;
		return;
	}

	// update auto-repeat
	if ( down )
	{
		key_reapeats[key]++;
		if ( key != K_BACKSPACE 
			&& key != K_PAUSE 
			&& key != K_PGUP 
			&& key != K_KP_PGUP 
			&& key != K_PGDN
			&& key != K_KP_PGDN
			&& key_repeats[key] > 1 )
			return;	// ignore most autorepeats
		if (key >= 200 && !keybindings[key])
			command->printf("%s is unbound, hit F4 to set.\n", key_keynum_to_string (key) );
	}
	else
	{
		key_repeats[key] = 0;
	}

	if (key == K_SHIFT)
		shift_down = down;

	// console key
	if ( key == '`' || key == '~' )
	{
		if ( !down )
			return;
		toggle_console_f();
		return;
	}

